<?php
$fid = JRequest::getInt('fid', 0);
$start = JRequest::getString('start', '');
$end = JRequest::getString('end', '');
$datetype = JRequest::getString('datetype', '');
$xtypes = array('resume', 'event', 'offer', 'entry');

$jobList = $_['jobList'];
$pagination = $_['pagination'];
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
   <tr>
      <th width="24%">职位名称</th>
      <th width="14%">新增简历</th>
      <th width="14%">进入面试</th>
      <th width="14%">发offer</th>
      <th width="14%">入职</th>
      <th width="20%">详细报表</th>
   </tr>
   <? if (!empty($jobList)): 
         foreach ($jobList as $l):
   ?>
      <tr>
         <td class="tleft"><a title="<?=$l['job_title']?>" href="<?=OC_Helper::linkToRoute("jobpos_setup", array('id'=>$l['job_id'], 'job_title'=>$l['job_title']))?>"><?=strmaxwordlen($l['job_title'], 32)?></a></td>
         <? foreach ($xtypes as $x): ?>
         <td><?=(!empty($l['total'][$x]) ? $l['total'][$x] : 0)?></td>
         <? endforeach; ?>
         <td class="rep_tdaction medium"><a href="<?=OC_Helper::linkToRoute("reports_positiondetail", array('jobid' => $l['job_id'], 'start' => $start, 'end' => $end, 'datetype' => $datetype))?>">查看</a> <div class="hide"><a href="#">导出</a> <a href="#">打印</a></div></td>
      </tr>
   <? 
         endforeach;
      else: 
   ?>
      <tr><td colspan="6"><div class="nodatacolor">暂无数据</div></td></tr>
   <? endif; ?>
</table>
<?php if ($pagination->pagesTotal > 1): ?>
<div id="jobListPagination" data-fid="<?=$fid?>" data-start="<?=$start?>" data-end="<?=$end?>" data-datetype="<?=$datetype?>"></div>
<script language="javascript" type="text/javascript">
   jQuery(document).ready(function() {
      var fid = $('#jobListPagination').data('fid');
      var start = $('#jobListPagination').data('start');
      var end = $('#jobListPagination').data('end');
      var datetype = $('#jobListPagination').data('datetype');
      jQuery.ajaxSetup({ cache: false });
      jQuery("#jobListPagination").pager({
         pageCount: <?php echo $pagination->pagesTotal; ?>,
         currentPage: <?php echo $pagination->pagesCurrent - 1; ?>
      }).delegate("li.active", "click", function(e) {
         var page = parseInt($(this).attr('page'));
         var url = getUrlQuery("<?=OC_Helper::linkTo('reports','ajax/getjoblist.php')?>", "limitstart=" + (page * <?=$pagination->limit?>));
         var target = jQuery(this);
         jQuery.ajax({
            url: url,
            data: {fid: fid,start: start, end: end, datetype: datetype},
            beforeSend: function(xhr, settings) {
               showLoading(target, settings, null, {button:true});
            },
            success: function(result) {
               jQuery("#jobList").html(result);
            }
         })
      }).parent().show();
   })
</script>
<?php endif; ?>